<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <form name="addItem" method="post" lay-filter="component-form-group" class="layui-form">
          <input type="hidden" value="<!--{$datainfo.id}-->" name="id">
          <input type="hidden" value="<!--{$datainfo.aid}-->" name="aid">

          <div class="layui-text-item">
            <div class="layui-text-line">
              <label class="layui-text-label"><!--{$lang.page.table.buyingp}--></label>
              <div class="layui-text-inline">
                    <!--{$datainfo.buyprice}-->
              </div>
            </div>
            <div class="layui-text-line">
              <label class="layui-text-label"><!--{$lang.page.table.sellingp}--></label>
              <div class="layui-text-inline">
                    <!--{$datainfo.sellprice}-->
              </div>
            </div>
            <div class="layui-text-line">
              <label class="layui-text-label"><!--{$lang.page.table.profitloss}--><!--{$lang.page.table.ipoint}--><!--{$lang.page.public.multiple}--></label>
              <div class="layui-text-inline">
                  <!--{$datainfo.wlpoint}-->
              </div>
            </div>
            <div class="layui-text-line">
              <label class="layui-text-label"><!--{$lang.page.table.profitloss}--></label>
              <div class="layui-text-inline">
                  <!--{$datainfo.money}-->
              </div>
            </div>
            <div class="layui-text-line">
              <label class="layui-text-label"><!--{$lang.page.table.mouths}--></label>
              <div class="layui-text-inline">
                  <!--{$datainfo.puffs}-->
              </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.profitloss}--> <!--{$lang.page.table.float}--></label>
              <div class="layui-input-block">
                <input type="text" name="drift" value="<!--{$datainfo.drift}-->" lay-verify="drift" class="layui-input">
              </div>
            </div>
          </div>

          <div class="layui-form-item layui-layout-admin">
            <div>
              <div class="layui-footer" style="margin-bottom: 10px">
                <button  class="layui-btn" type="button" id="submit" lay-submit lay-filter="submit"><!--{$lang.page.public.submit}--></button>
                <button type="reset" id='reset' class="layui-btn layui-btn-primary"><!--{$lang.page.public.reset}--></button>
                <button type="button" class="layui-btn layui-btn-primary" onClick="xadmin.close();" ><!--{$lang.page.table.back}--></button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
<script src="/static/lay/layui/layui.js"></script>
  <script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer','xadmin', 'form'], function(){
    var form = layui.form;
    form.render(null, 'component-form-group');

    form.verify({
      drift: function(value){
        if(value.length < 1){
          return '<!--{$lang.page.public.parameter}--> <!--{$lang.page.public.nocontent}-->';
        }else{
          if(!(/^[+-]?\d*\.?\d*$/).test(value)){
            return '<!--{$lang.page.public.paraerror}-->';
          }
          if(value>50 || value<-50){
            return '<!--{$lang.page.public.paraerror}-->';
          };
        }
      }    
    });

    form.on('submit(submit)', function (data) {
        layer.alert('<!--{$lang.page.public.tradeerror}-->', {
                offset:'50px'
                , closeBtn: 1 // 是否显示关闭按钮
                , anim: 1 //动画类型
                , btn: ['<!--{$lang.page.table.confirm}-->', '<!--{$lang.page.table.cancel}-->'] //按钮
                , icon: 6 // icon
                , yes: function () {
                    $('#submit').attr("disabled",true);
                    $('#submit').addClass('layui-btn-disabled');
                    $.post('#',data.field,function(res){
                        if(res.code == 200){
                            layer.msg(res.msg);
                            setTimeout(() => {
                                window.parent.location.reload();
                                xadmin.close();
                            }, 1000);
                        }else{
                          $('#submit').removeAttr("disabled");
                          $('#submit').removeClass('layui-btn-disabled');
                          layer.msg(res.msg);
                        }
                    })
                    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
                }
        });
    });
    //重置按钮，可以提交失败的时候再次提交
    $('#reset').click(function(){
        $('#submit').removeAttr("disabled");
        $('#submit').removeClass('layui-btn-disabled');
    });
  });
  </script>
</body>
</html>